import React from 'react';
import { Button, Form, Input } from 'antd';

import {useSelector} from 'react-redux';

const FormComponent = ({labels}) => {
  const onFinish = (values) => {
    console.log('Success:', values);
  };
  const onFinishFailed = (errorInfo) => {
    console.log('Failed:', errorInfo);
  };

  const languages = useSelector((state) =>state).publicReducer.language
  return (
    <Form
      name="basic"
      labelCol={{
        span: 8,
      }}
      wrapperCol={{
        span: 8,
      }}
      onFinish={onFinish}
      onFinishFailed={onFinishFailed}
      autoComplete="off"
    >
      <Form.Item
        label={labels.label1+":"}
        name={labels.label1}
        rules={[
          {
            required: true,
            message: languages==='Korean'?'사용자 입력':languages==="English"?'Please input your':'请输入您的'+ labels.label1 + "!",
          },
        ]}
      >
        <Input />
      </Form.Item>

      <Form.Item
        label={labels.label2 + ":"}
        name={labels.label2}
        rules={[
          {
            required: true,
            message: languages==='Korean'?'사용자 입력':languages==="English"?'Please input your':'请输入您的'+ labels.label2 + "!",
          },
        ]}
      >
        <Input />
      </Form.Item>

      <Form.Item
        wrapperCol={{
          offset: 7,
          span: 9,
        }}
      >
        <Button type="primary" htmlType="submit">
          {labels.Submit}
        </Button>
      </Form.Item>
    </Form>
  );
};
export default FormComponent;